@extends('layout.master')

@section('title','添加专题')

@section('css')
    @parent
    <link href="{{ asset('plugins/bower_components/summernote/dist/summernote.css') }}" rel="stylesheet"/>
    <!-- animation CSS -->
    <link href="{{ asset('css/animate.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/icheck/skins/all.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.css') }}" rel="stylesheet">
@endsection
@section('main')

    @if (session('message'))
        <div>
            <input type="hidden" id="hidden" name="hidden" value="hidden">
            <input type="hidden" id="message" name="message" value="{{ session('message') }}">
            <input type="hidden" id="status" name="status" value="{{ session('status') }}">
        </div>
    @endif

   

        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <form class="form-horizontal form-material" id="modify" method="post" enctype="multipart/form-data">
				        <div class="form-group m-b-40 m-t-10" style="overflow: visible;">
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">子分类标题</label>
								<input type="text" class="form-control" id="name" name="name" required value="{{$Ztlist->name}}"><span class="highlight"></span> <span class="bar"></span>
							</div>
							
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">所属分类</label>
                                <select style="height: 38px" name="tag_id">
                                    @foreach(App\Ztfenlei::select('id', 'name')->where('is_del', 1)->get() as $value)
                                        <option value="{{ $value->id }}" @if(intval($Ztlist->tag_id) === intval($value->id)) selected @endif>{{ $value->name }}</option>
                                    @endforeach
                                </select>
							</div>
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
                                <label class="col-md-12">子分类图标</label>
                                <div class="col-md-12">
                                    <div class="form-group ">
                                        <input type="file" id="input-file-now-custom-3" class="dropify"
                                               name="pic_path"
                                               data-default-file="{{$Ztlist->pic_path}}"
                                               data-height="200px"/>
                                    </div>
                                </div>
                            </div>
							<div class="form-group m-b-40 m-t-10">
								<p for="remarks">内容</p>
								<textarea id="contents" name="contents" cols="80" rows="5">{{$Ztlist->content}}</textarea>
								<textarea id="contents1" name="content" cols="80" rows="5" style="display:none;">{{$Ztlist->content}}</textarea>
							</div>
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">子标题1</label>
								<input type="text" class="form-control" id="title1" name="title1" value="{{$Ztlist->title1}}" required><span class="highlight"></span> <span class="bar"></span>
							</div>
							<div class="form-group m-b-40 m-t-10">
								<p for="remarks">子内容1</p>
								<textarea id="remaker1" name="content1" cols="80" rows="5">{{$Ztlist->remaker1}}</textarea>
								<textarea id="content1" name="remaker1" cols="80" rows="5" style="display:none;">{{$Ztlist->remaker1}}</textarea>
							</div>
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">子标题2</label>
								<input type="text" class="form-control" id="title2" name="title2" value="{{$Ztlist->title2}}"><span class="highlight"></span> <span class="bar"></span>
							</div>
							<div class="form-group m-b-40 m-t-10">
								<p for="remarks">子内容2</p>
								<textarea id="remaker2" name="content2" cols="80" rows="5">{{$Ztlist->remaker2}}</textarea>
								<textarea id="content2" name="remaker2" cols="80" rows="5" style="display:none;">{{$Ztlist->remaker2}}</textarea>
							</div>	
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">子标题3</label>
								<input type="text" class="form-control" id="title3" name="title3" value="{{$Ztlist->title3}}"><span class="highlight"></span> <span class="bar"></span>
							</div>
							<div class="form-group m-b-40 m-t-10">
								<p for="remarks">子内容3</p>
								<textarea id="remaker3" name="content3" cols="80" rows="5">{{$Ztlist->remaker3}}</textarea>
								<textarea id="content3" name="remaker3" cols="80" rows="5" style="display:none;">{{$Ztlist->remaker3}}</textarea>
							</div>
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">子标题4</label>
								<input type="text" class="form-control" id="title4" name="title4"  value="{{$Ztlist->title4}}"><span class="highlight"></span> <span class="bar"></span>
							</div>
							<div class="form-group m-b-40 m-t-10">
								<p for="remarks">子内容4</p>
								<textarea id="remaker4" name="content4" cols="80" rows="5">{{$Ztlist->remaker4}}</textarea>
								<textarea id="content4" name="remaker4" cols="80" rows="5" style="display:none;">{{$Ztlist->remaker4}}</textarea>
							</div>
							<div class="form-group m-b-40 m-t-10" style="width:726px;">
								<label for="title">子标题5</label>
								<input type="text" class="form-control" id="title5" name="title5" value="{{$Ztlist->title5}}"><span class="highlight"></span> <span class="bar"></span>
							</div>
							<div class="form-group m-b-40 m-t-10">
								<p for="remarks">子内容5</p>
								<textarea id="remaker5" name="content5" cols="80" rows="5">{{$Ztlist->remaker5}}</textarea>
								<textarea id="content5" name="remaker5" cols="80" rows="5" style="display:none;">{{$Ztlist->remaker5}}</textarea>
							</div>							
						</div>
						
						
                    <div class="row">
                        <div class="form-group"> 
                            <a class="fcbtn btn btn-success btn-outline btn-1e waves-effect"
                               href="/zixun/ztlist/">返回列表
                            </a>
                            <button type="button" class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="publish">确定
                            </button>
                            {!! csrf_field() !!}
                        </div>
                    </div>
                </form>
            </div>
        </div>
    

@endsection
@section('js')
    @parent
    <!-- icheck -->
    <script src="{{ asset('plugins/bower_components/icheck/icheck.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/icheck/icheck.init.js') }}"></script>
    <script src="{{ asset('js/jasny-bootstrap.js') }}"></script>
    <!-- jQuery file upload -->
    <script src="{{ asset('plugins/bower_components/dropify/dist/js/dropify.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/summernote/dist/summernote.min.js') }}"></script>
    <script>
        $(document).ready(function () {
            // Basic
            $('.dropify').dropify();
        });
    </script>
    <script src="{{ asset('plugins/bower_components/bootstrap-select/bootstrap-select.min.js') }}"
            type="text/javascript"></script>
    <!-- bt-switch -->
    <script src="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.js') }}"></script>
    <script type="text/javascript">
        jQuery(document).ready(function () {

            $('#contents').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
            lang: 'zh-CN',
            placeholder: '内容',
            dialogsFade: true,
            callbacks: {
                onImageUpload: function (files) {
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        data: data,
                        type: "POST",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: "/upload", /*填写后台上传文件的路径*/
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (url) {/*url为上传成功后返回的图片路径*/
                            var imgNode = document.createElement('img');
                            imgNode.src = url+'?x-oss-process=image/resize,w_500';
                            $('#contents').summernote('insertNode', imgNode);
                        }
                    })
                }
            }
         });
		 
        $('#remaker1').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
            lang: 'zh-CN',
            placeholder: '内容',
            dialogsFade: true,
            callbacks: {
                onImageUpload: function (files) {
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        data: data,
                        type: "POST",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: "/upload", /*填写后台上传文件的路径*/
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (url) {/*url为上传成功后返回的图片路径*/
                            var imgNode = document.createElement('img');
                            imgNode.src = url+'?x-oss-process=image/resize,w_500';
                            $('#remaker1').summernote('insertNode', imgNode);
                        }
                    })
                }
            }
         });
		 
        $('#remaker2').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
            lang: 'zh-CN',
            placeholder: '内容',
            dialogsFade: true,
            callbacks: {
                onImageUpload: function (files) {
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        data: data,
                        type: "POST",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: "/upload", /*填写后台上传文件的路径*/
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (url) {/*url为上传成功后返回的图片路径*/
                            var imgNode = document.createElement('img');
                            imgNode.src = url+'?x-oss-process=image/resize,w_500';
                            $('#remaker2').summernote('insertNode', imgNode);
                        }
                    })
                }
            }
         });
		 
        $('#remaker3').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
            lang: 'zh-CN',
            placeholder: '内容',
            dialogsFade: true,
            callbacks: {
                onImageUpload: function (files) {
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        data: data,
                        type: "POST",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: "/upload", /*填写后台上传文件的路径*/
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (url) {/*url为上传成功后返回的图片路径*/
                            var imgNode = document.createElement('img');
                            imgNode.src = url+'?x-oss-process=image/resize,w_500';
                            $('#remaker3').summernote('insertNode', imgNode);
                        }
                    })
                }
            }
         });
		 
        $('#remaker4').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
            lang: 'zh-CN',
            placeholder: '内容',
            dialogsFade: true,
            callbacks: {
                onImageUpload: function (files) {
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        data: data,
                        type: "POST",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: "/upload", /*填写后台上传文件的路径*/
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (url) {/*url为上传成功后返回的图片路径*/
                            var imgNode = document.createElement('img');
                            imgNode.src = url+'?x-oss-process=image/resize,w_500';
                            $('#remaker4').summernote('insertNode', imgNode);
                        }
                    })
                }
            }
         });
		 
        $('#remaker5').summernote({
                height: 350, // set editor height
                minHeight: null, // set minimum height of editor
                maxHeight: null, // set maximum height of editor
                focus: false, // set focus to editable area after initializing summernote$('.summernote').summernote({
                toolbar: [
                    // [groupName, [list of button]]
                    ['style', ['bold', 'italic', 'underline', 'clear']],
                    ['fontsize', ['fontsize']],
                    ['fontname', ['fontname']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                    ['height', ['height']],
                    ['insert', ['link', 'picture', 'video']],
                    ['view', ['fullscreen', 'codeview', 'help']]
                ],
            lang: 'zh-CN',
            placeholder: '内容',
            dialogsFade: true,
            callbacks: {
                onImageUpload: function (files) {
                    var data = new FormData();
                    data.append("file", files[0]);
                    $.ajax({
                        data: data,
                        type: "POST",
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        url: "/upload", /*填写后台上传文件的路径*/
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (url) {/*url为上传成功后返回的图片路径*/
                            var imgNode = document.createElement('img');
                            imgNode.src = url+'?x-oss-process=image/resize,w_500';
                            $('#remaker5').summernote('insertNode', imgNode);
                        }
                    })
                }
            }
         });


        });

        $(".bt-switch input[type='checkbox'], .bt-switch input[type='radio']").bootstrapSwitch();
        var radioswitch = function () {
            var bt = function () {
                $(".radio-switch").on("switch-change", function () {
                    $(".radio-switch").bootstrapSwitch("toggleRadioState")
                }),
                    $(".radio-switch").on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck")
                    }),
                    $(".radio-switch").on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck", !1)
                    })
            };
            return {
                init: function () {
                    bt()
                }
            }
        }();
        $(document).ready(function () {
            radioswitch.init()
        });
		
       $("#publish").click(function (e) {
			var data = $("#contents").val();
			$("#contents1").html(data);
			
			var name = $("#name").val();
			var tag_id = $("#tag_id").val();
			
			var title1 = $("#title1").val();
			var data1 = $("#remaker1").val();
			$("#content1").html(data1);
			
			var data2 = $("#remaker2").val();
			$("#content2").html(data2);
			
			var data3 = $("#remaker3").val();
			$("#content3").html(data3);
			
			var data4 = $("#remaker4").val();
			$("#content4").html(data4);
			
			var data5 = $("#remaker5").val();
			$("#content5").html(data5);

			if(name==''){
				swal("分类标题不能为空!");
				return false;
			}
			if(tag_id==''){
				swal("请选择分类!");
				return false;
			}
			if(data==''){
				swal("内容不能为空!");
				return false;				
			}
			if(title1==''){
				swal("子标题不能为空!");
				return false;
			}
			if(data1==''){
				swal("子内容不能为空!");
				return false;				
			}			
			
			document.getElementById("modify").submit();
	   });

        $(document).ready(function () {
            var hidden = $('#hidden').val();
            if (hidden === 'hidden') {
                if ($('#status').val() == 1) {
                    toastsuccess($('#message').val());
                } else {
                    toasterror($('#message').val());
                }
            }
        });


    </script>
@endsection